

'''登录页'''
from selenium.webdriver.common.by import By

from page_objects.base_page import BasePage


class LoginPage(BasePage):

    _BASE_URL = "https://litemall.hogwarts.ceshiren.com/#/login"

    _NAMR_OBJECT = (By.NAME, "username")
    _PASSWORD_ELEMENT = (By.NAME, "password")
    _BUTTON_ = (By.CSS_SELECTOR, ".el-button--primary")

    def login(self):

        # 访问登录页

        # self.driver.get("https://litemall.hogwarts.ceshiren.com/")
        # 输入“用户名”
        self.do_send_keys("manage", self._NAMR_OBJECT)

        # 输入密码
        # self.driver.find_element(By.NAME, "password").clear()
        # self.driver.find_element(By.NAME, "password").send_keys("manage123")
        self.do_send_keys("manage123", self._PASSWORD_ELEMENT)

        # 点击"登录"按钮
        self.do_find(self._BUTTON_).click()

        # ==> 首页
        from page_objects.home_page import HomePage
        return HomePage(self.driver)

